import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/home/home.vue'
import indexView from '@/views/home/index.vue'
import calView from '@/views/home/cal.vue'
import cartView from '@/views/home/cart.vue'
import myView from '@/views/home/my.vue'
import ssView from '@/views/home/ss.vue'
import splbView from '@/views/home/splb.vue'
import xqView from '@/views/home/xq.vue'
import zcView from '@/views/home/zc.vue'
import dlView from '@/views/home/dl.vue'
import ddymView from '@/views/home/ddym.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/', redirect: '/home/index'
    },
    {
      path: '/home', component: HomeView, children: [
        { path: 'index', component: indexView },
        { path: 'cal', component: calView },
        { path: 'cart', component: cartView },
        { path: 'my', component: myView },
      ]
    },
    {
      path: '/ss', component: ssView,
    },
    {
      path: '/splb/:query', component: splbView,
    },
    {
      path: '/xq/:goods_id', component: xqView,
    },
    {
      path: '/zc', component: zcView,
    },
    {
      path: '/dl', component: dlView,
    },
    {
      path: '/ddym', component: ddymView,
    },
  ],
})
// router.beforeEach((to, from, next) => {
//   let token = localStorage.getItem('token')
//   if (to.fullPath == '/home/cart' || to.fullPath == '/home/my') {
//     if (!token) {
//       next('/dl')
//     } else {
//       next()
//     }
//   } else {
//     next()
//   }
// })
export default router
